<script setup lang="ts">
import type { TreeNodeData } from '@arco-design/web-vue'
import { useOrg } from '@/hooks'

const model = defineModel<string | number | Array<any>>()

const { orgTree, getOrgTree } = useOrg()

// 过滤部门
const filterOrgOptions = (searchKey: string, nodeData: TreeNodeData) => {
  if (nodeData.title) {
    return nodeData.title.toLowerCase().includes(searchKey.toLowerCase())
  }
  return false
}

onMounted(() => {
  getOrgTree()
})
</script>

<template>
  <a-tree-select
    v-model="model"
    :data="orgTree"
    placeholder="请选择组织"
    allow-clear
    allow-search
    :filter-tree-node="filterOrgOptions"
  />
</template>

<style scoped>

</style>
